function getNumLines(cfile) result(n)
 
   implicit none
   character(len=*), intent(in) :: cfile
   integer(kind=4) :: n
   integer(kind=4) :: io
   
   n = 0
   open(1,file=cfile,status='old')
   read(1,*,iostat=io)  
   do while (io.eq.0)
      n = n + 1
      read(1,*,iostat=io)
   enddo
   close(1)
   
   

end function getNumLines
